/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.appspot.trick.it.admin.bind;

import com.appspot.trick.it.admin.task.ArticleAddTask;
import com.appspot.trick.it.admin.task.ArticleChangeIndexTask;
import com.appspot.trick.it.admin.task.ArticleDeleteTask;
import com.appspot.trick.it.admin.task.ArticleLoadListTask;
import com.appspot.trick.it.admin.task.ArticleUpdateTitleTask;
import javafx.beans.binding.BooleanBinding;

/**
 *
 * @author imamura
 */
public class ArticleTreeProgressVisibleBinding extends BooleanBinding {
    
    private final ArticleLoadListTask articleLoadListTask;
    private final ArticleUpdateTitleTask articleUpdateNameTask;
    private final ArticleAddTask articleAddTask;
    private final ArticleDeleteTask articleDeleteTask;
    private final ArticleChangeIndexTask articleChangeIndexTask;
    

    /**
     * コンストラクタ
     * @param articleLoadListTask
     * @param articleUpdateNameTask
     * @param articleAddTask
     * @param articleDeleteTask
     * @param articleChangeIndexTask
     */
    public ArticleTreeProgressVisibleBinding(
            ArticleLoadListTask articleLoadListTask,
            ArticleUpdateTitleTask articleUpdateNameTask,
            ArticleAddTask articleAddTask,
            ArticleDeleteTask articleDeleteTask,
            ArticleChangeIndexTask articleChangeIndexTask
            ) {
        this.articleLoadListTask = articleLoadListTask;
        this.articleUpdateNameTask = articleUpdateNameTask;
        this.articleAddTask = articleAddTask;
        this.articleDeleteTask = articleDeleteTask;
        this.articleChangeIndexTask = articleChangeIndexTask;

        super.bind(articleLoadListTask.runningProperty());
        super.bind(articleUpdateNameTask.runningProperty());
        super.bind(articleAddTask.runningProperty());
        super.bind(articleDeleteTask.runningProperty());
        super.bind(articleChangeIndexTask.runningProperty());
    }

    @Override
    protected boolean computeValue() {

        if(articleLoadListTask.runningProperty().getValue()) return true;
        if(articleUpdateNameTask.runningProperty().getValue()) return true;
        if(articleAddTask.runningProperty().getValue()) return true;
        if(articleDeleteTask.runningProperty().getValue()) return true;
        if(articleChangeIndexTask.runningProperty().getValue()) return true;
        
        return false;
    }
}
